package com.yoso.classload;

import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.jar.JarFile;

/**
 * @author shizejin
 * @date 2021/12/10
 * @description:
 */
public class LoaderTest {
    public static void main(String[] args) {
        Path path = Paths.get("J:\\database\\Oracle\\jar", "ojdbc6.jar");
        try {

            JarFile jarFile = new JarFile("J:\\database\\Oracle\\jar\\ojdbc6.jar");
/*            Enumeration<JarEntry> entries = jarFile.entries();
            while (entries.hasMoreElements()){
                JarEntry jarEntry = entries.nextElement();
                String name = jarEntry.getName();
                System.out.println(name);
            }*/
            MyClassLoader myClassLoader = new MyClassLoader();
            String name = "oracle.jdbc.driver.OracleDriver";
            Class<?> aClass = myClassLoader.findClass(name);
            Object user = aClass.newInstance();
            System.out.println(user);
            String simpleName = aClass.getSimpleName();
            System.out.println("simpleName = " + simpleName);
            System.out.println("aClass.isInterface() = " + aClass.isInterface());

        } catch (MalformedURLException | IllegalAccessException | InstantiationException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
